<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>千千音乐盒</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .pannel{
            position: relative;
            width: 400px;
            height: 350px;
            margin: 100px auto;
            border: 1px solid #ddd;
            padding: 20px 20px;
        }
        .pannel .panel-title{
            position: relative;
            width: 100%;
            height: 60px;
            margin: 10px auto;
            border-bottom: 1px solid #ddd;
        }
        .pannel .panel-title h2{
            text-align: center;
        }
        .pannel .panel-contant{
            position: relative;
            width: 100%;
            height: 220px;
            font-size: 20px;
            box-sizing: border-box;
            padding: 20px 20px;
            border-bottom: 1px solid #ddd;
        }
        .button{
            text-align: center;
            margin: 20px auto;
        }
        .button button{
            padding: 8px;
        }
    </style>
</head>
<body>
    <div class="pannel">
        <div class="panel-title">
            <h2>千千音乐盒</h2>
        </div>
        <div class="panel-contant">
            <input type="checkbox" name="" id="">漂洋过海来看你<br>
            <input type="checkbox" name="" id="">漂洋过海来看你<br>
            <input type="checkbox" name="" id="">漂洋过海来看你<br>
            <input type="checkbox" name="" id="">漂洋过海来看你<br>
            <input type="checkbox" name="" id="">漂洋过海来看你<br>
            <input type="checkbox" name="" id="">漂洋过海来看你<br>
            <input type="checkbox" name="" id="">漂洋过海来看你<br>
        </div>
        <div class="button">
            <button id="allSelect">全选</button>
            <button id ="cancelSelect">取消全选</button>
            <button id ="fanSelect">反选</button>
        </div>
    </div>
    <script>
        function $(id){
            return typeof id==="string" ? document.getElementById(id):null;
        }
        var inputs = document.getElementsByTagName("input");
        $('allSelect').onclick = function(){
            for(var i = 0;i < inputs.length;i++){
                inputs[i].checked = true;
            }
        }
        $('cancelSelect').onclick = function(){
            for(var i = 0;i < inputs.length;i++){
                inputs[i].checked = false;
            }
        }
        $('fanSelect').onclick = function(){
            for(var i = 0;i < inputs.length;i++){
                inputs[i].checked = !inputs[i].checked;
            }
        }
    </script>
</body>
</html>